package com.xiexie.order.interceptor.feign;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.UUID;

/**
 * @Description 自定义openFeign拦截器
 * @Date 2022-04-11 16:11
 * @Author xie
 */
public class CustomFeignInterceptor implements RequestInterceptor {

    private static final Logger LOGGER = LoggerFactory.getLogger(CustomFeignInterceptor.class);

    public void apply(RequestTemplate requestTemplate) {
        // 可以做拦截处理，比如认证或者日志等
        LOGGER.info("feign拦截器");
        String access_token = UUID.randomUUID().toString();
        requestTemplate.header("Authorization", access_token);
        //requestTemplate.uri();
    }
}
